package org.soenea.doitall.domain.model.user;

import org.dsrg.soenea.domain.DomainObjectCreationException;
import org.dsrg.soenea.domain.MapperException;
import org.dsrg.soenea.domain.proxy.DomainObjectProxy;
import org.soenea.doitall.domain.model.user.mapper.UserInputMapper;

public class UserProxy extends DomainObjectProxy<Long, User> implements
		IUser {

	public UserProxy(Long id) {
		super(id);
	}

	@Override
	public long getGroupID() {
	return getInnerObject().getGroupID();
	}


	@Override
	public void setGroupID(long groupID) {
		getInnerObject().setGroupID(groupID);
	}
	@Override
	public String getUserName() {
		return getInnerObject().getUserName();
	}

	@Override
	public void setUserName(String userName) {
		getInnerObject().setUserName(userName);
	}

	@Override
	public String getFirstName() {
		return getInnerObject().getFirstName();
	}

	@Override
	public void setFirstName(String firstName) {
		getInnerObject().setFirstName(firstName);
	}

	@Override
	public String getLastName() {
		return getInnerObject().getLastName();
	}

	@Override
	public void setLastName(String lastName) {
		getInnerObject().setLastName(lastName);
	}

	@Override
	public String getPassword() {
		return getInnerObject().getPassword();
	}

	@Override
	protected User getFromMapper(Long id) throws MapperException,
			DomainObjectCreationException {
		try{
			return UserInputMapper.find(id);
		}catch (Exception e) {
			throw new DomainObjectCreationException(e.getMessage(),e);
		}
	}

	@Override
	public void setAdmin(boolean admin) {
		getInnerObject().setAdmin(admin);
	}

	@Override
	public boolean isAdmin() {
		return getInnerObject().isAdmin();
	}
	
}
